// -*- C++ -*-

#pragma once

#include <os.hpp>
#include <vector>

class SystemLog
{
public:
  enum Flags {
    PANIC   = 0x1,
    REBOOT  = 0x2
  };

  // append @bytes to the system log
  static void write(const char*, size_t);

  // retrieve a copy of the memory-stored system log
  static std::vector<char> copy();

  // send whole system log to stdout @function
  static void print_to(os::print_func function);

  // set and get global bits
  static uint32_t get_flags();
  static void     set_flags(uint32_t flags);
  static void     clear_flags();

  // platform will initialize (create new or restore)
  static void initialize();
};


inline void SystemLog::print_to(os::print_func funcptr)
{
  auto copy = SystemLog::copy();
  if (not copy.empty()) funcptr(copy.data(), copy.size());
}
